home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1 / lisp / mac / Menus.el < prev    next >
Encoding:
Text File  |  1994-02-23  |  3.1 KB  |  126 lines  |  [TEXT/EMAC]

  1. ;;;
  2. ;;; This file is part of a Macintosh port of GNU Emacs.
  3. ;;;
  4. ;;; GNU Emacs is distributed in the hope that it will be useful,
  5. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  6. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  7. ;;; GNU General Public License for more details.
  8. ;;;
  9.  
  10. ; pascal void CheckItem(MenuHandle theMenu,short item,Boolean checked)
  11. ;    = 0xA945; 
  12. (deftrap CheckItem ("a945")
  13.   ((theMenu long)
  14.    (item short)
  15.    (check char))
  16.   nil)
  17.  
  18. ; pascal MenuHandle NewMenu(short menuID,const Str255 menuTitle)
  19. ;    = 0xA931; 
  20. (deftrap NewMenu-internal ("a931")
  21.   ((menuID short)
  22.    (menuTitle address))
  23.   long)
  24.  
  25. (defun NewMenu (menuID menuTitle)
  26.   (NewMenu-internal menuID (CtoPstr menuTitle)))
  27.  
  28. (defun MenuList ()
  29.   (extract-internal 2588 0 'unsigned-long))
  30.  
  31. ; pascal void InsertMenu(MenuHandle theMenu,short beforeID)
  32. ;    = 0xA935; 
  33. (deftrap InsertMenu-internal ("a935")
  34.   ((theMenu long)
  35.    (beforeID short))
  36.   nil)
  37.  
  38. (defun InsertMenu (theMenu beforeID)
  39.   (if (numberp beforeID)
  40.       (InsertMenu-internal theMenu beforeID)
  41.     (let* ((mlist (MenuList)))
  42.       (HLock mlist)
  43.       (let* ((menus-so-far (/ (extract-internal (deref mlist) 0 'short) 6))
  44.          (beforeID (if (zerop menus-so-far)
  45.                0
  46.              (let ((first-menu-handle (deref (+ (deref mlist) 6))))
  47.                (prog2
  48.                 (HLock first-menu-handle)
  49.                 (extract-internal (deref first-menu-handle) 0 'short)
  50.                 (HUnlock first-menu-handle))))))
  51.     (HUnlock mlist)
  52.     (InsertMenu-internal theMenu beforeID)))))
  53.  
  54. ; pascal MenuHandle GetMHandle(short menuID)
  55. ;    = 0xA949; 
  56. (deftrap GetMHandle ("a949")
  57.   ((menuID short))
  58.   long)
  59.  
  60. ; pascal void AppendMenu(MenuHandle menu,ConstStr255Param data)
  61. ;    = 0xA933; 
  62. (deftrap AppendMenu-internal ("a933")
  63.   ((menu long)
  64.    (data address))
  65.   nil)
  66.  
  67. (defvar mac-menu-callback-list nil)
  68.  
  69. (defun AppendMenu (menu data callback)
  70.   (AppendMenu-internal menu (CtoPstr data))
  71.   (setq mac-menu-callback-list (cons (cons (cons menu (CountMItems menu)) callback)
  72.                                      mac-menu-callback-list)))
  73.  
  74. ; pascal short CountMItems(MenuHandle theMenu)
  75. ;    = 0xA950; 
  76. (deftrap CountMItems ("a950")
  77.   ((theMenu long))
  78.   short)
  79.  
  80. ; pascal void SetItem(MenuHandle theMenu,short item,ConstStr255Param itemString)
  81. ;    = 0xA947; 
  82. (deftrap SetItem-internal ("a947")
  83.   ((theMenu long)
  84.    (item short)
  85.    (itemString address))
  86.   nil)
  87.  
  88. (defun SetItem (theMenu item itemString)
  89.   (SetItem-internal theMenu item (CtoPstr itemString)))
  90.  
  91. ; pascal void SetItemMark(MenuHandle theMenu,short item,short markChar)
  92. ;    = 0xA944; 
  93. (deftrap SetItemMark ("a944")
  94.   ((theMenu long)
  95.    (item short)
  96.    (markChar short))
  97.   nil)
  98.  
  99. ; pascal void GetItem(MenuHandle theMenu,short item,Str255 itemString)
  100. ;    = 0xA946; 
  101. (deftrap GetItem ("a946")
  102.   ((theMenu long)
  103.    (item short)
  104.    (itemString address))
  105.   nil)
  106.  
  107. ; pascal void AddResMenu(MenuHandle theMenu,ResType theType)
  108. ;    = 0xA94D; 
  109. (deftrap AddResMenu ("a94d")
  110.   ((theMenu long)
  111.    (theType immediate-string))
  112.   nil)
  113.  
  114. ; pascal void DrawMenuBar(void)
  115. ;    = 0xA937; 
  116. (deftrap DrawMenuBar ("a937")
  117.   nil
  118.   nil)
  119.  
  120. ; pascal void DelMenuItem(MenuHandle theMenu,short item)
  121. ;    = 0xA952; 
  122. (deftrap DelMenuItem ("a952")
  123.   ((theMenu long)
  124.    (item short))
  125.   nil)
  126.